import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
  ],
  server: {
      fs: {
          strict: false // 允许跨目录访问
      }
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  build: {
    outDir: 'dist', // 确保输出目录是 dist
    assetsDir: 'assets', // 静态资源存放目录
    sourcemap: false, // 关闭 sourcemap 以减少包体积
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes('node_modules')) {
            return 'vendor'; // 单独拆分第三方依赖
          }
        }
      }
    }
  }
})
